<%@ page import="utils.Book" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <title>书籍详情页</title>
    <meta charset="utf-8">
    <script src="./bootstrap/js/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
    <script src="./bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/book.css">
    <script>
        function getNum(tag) {
            if(tag==1){
                if($("#count").val()>=2)
                     $("#count").val(parseInt($("#count").val())-1)
            }else{
                if($("#count").val()<=10)
                 $("#count").val(parseInt($("#count").val())+1)
            }
        }

        $(function () {
            $("#store").click(function () {
                $.ajax({
                    url:"/add?count="+$("#count").val(),
                    success:function (data) {
                        alert(data)
                    }
                })
            })
        })
    </script>
</head>
<body>
<div id="head">
    <img src="image/logo.jpg">
    <div class="input-group" id="search">
        <input type="text" class="form-control" placeholder="输入你要查找的图书或作者" aria-describedby="basic-addon2" size="10">
        <span class="input-group-addon" id="basic-addon2">搜索</span>
    </div>
    <% String user=(String)request.getSession().getAttribute("user");
        if (null==user)
            user="";
    %>
    <span id="hello"><%=user%><b>您好！欢迎来到西柚书屋！</b><a href="/store.jsp">查看购物车</a><a href="/ExitServlet">退出</a></span>
</div>
<div id="content">
        <% Book book=(Book)request.getAttribute("book");
            session.setAttribute("book",book);
        %>
        <img src="${book.url}">
        <form action="/showorder" method="post">
            <span>${book.name}</span><br>
            <span>${book.author}</span><br>
            <span>${book.publisher}</span><br>
            <span>${book.price}元</span><br>
            <input type="button"  onclick="getNum(1)" value="-">
            <input value="1" size="10" id="count" name="count">
            <input type="button"  onclick="getNum(2)" value="+">
            <input type="button" value="加入购物车" id="store">
            <input type="submit" value="立即购买">
        </form>
</div>
<footer>
    <br>关于我们 - 广告合作 - 联系我们 - 免责声明 - 网站地图 - 投诉建议 - 在线投稿<br>
    ©CopyRight 2006-2017 JB51.Net Inc All Rights Reserved. 西柚书屋
</footer>
</body>
</html>